<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/WEB-INF/jsp/commons/taglibs.jsp" %>
<!DOCTYPE HTML>
<html ng-app>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <META HTTP-EQUIV="pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
    <META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
    <title>${title}</title>
    <%@ include file="/WEB-INF/jsp/commons/meta.jsp" %>
    <link href="${ctx}/resources/new/style.css" type="text/css" rel="stylesheet"/>

</head>
<body>
<script>
    $(document).ready(function () {
        //聚焦第一个输入框
        $("#name").focus();
        //为inputForm注册validate函数
        $("#inputForm").validate({
            rules: {
                marchandise: "required",
                department: "required",
                salesState: "required",
                qrCode: "required",
                memo: "required"
            }
        });
    });
</script>
<form id="inputForm" class="well form-inline" action="${ctx}/adoms/goods/save" method="post">
    <input type="hidden" name="id" value="${goods.id}"/>
    <table class="table table-striped table-bordered table-condensed">
        <thead>
        <i class="icon-flag"></i>
        <strong>商品货物表单</strong>
        </thead>
        <tr>
            <td class="span2">所属商品:</td>
            <td>
                <select id="marchandise" name="marchandise.id">
                    <c:forEach items="${mList }" var="m" varStatus="index">
                        <option value="${m.id }"
                                <c:if test="${goods.marchandise.id == m.id }">selected</c:if>>${index.index + 1}.${m.name }</option>
                    </c:forEach>
                </select>
            </td>
        </tr>
        <tr>
            <td>所属部门:</td>
            <td>
                <input id="department" name="department.id" type="hidden" value="${goods.department.id}" size="30"
                       maxlength="80"/>
                ${goods.department.name}
                <c:if test="${not empty(goods.produceDate) }">
                    <input id="produceDate" name="produceDate" type="hidden" value="${goods.produceDate}" size="30"
                           maxlength="80"/>
                </c:if>
            </td>
        </tr>
        <c:if test="${not empty(goods.order.id) }">
            <tr class="hide">
                <td>所属订单:</td>
                <td>
                    <input id="order" name="order.id" type="hidden" value="${goods.order.id}" size="30" maxlength="80"/>
                </td>
            </tr>
        </c:if>
        <tr>
            <td>状态:</td>
            <td>
                <select id="state" name="state">
                    <option <c:if test="${empty(goods.state) }">selected</c:if>>待售</option>
                    <option <c:if test="${goods.state == '已售' }">selected</c:if>>已售</option>
                    <option <c:if test="${goods.state == '已出库' }">selected</c:if>>已出库</option>
                </select>
            </td>
        </tr>
        <tr>
            <td valign="top">货物二维码:</td>
            <td>
                <input id="qrCode" name="qrCode.id" type="hidden" value="${goods.qrCode.id}" size="30" maxlength="80"/>
                <img src="${ctx}/adoms/qrGoodsCode/qrImg?qr=${goods.qrCode.qrCode}"/>

                <p>
                    ${goods.qrCode.qrCode}
                </p>
            </td>
        </tr>
        <tr>
            <td>流水码:</td>
            <td>
                ${goods.qrCode.iCode}
            </td>
        </tr>
        <tr>
            <td>生产日期:</td>
            <td>
                <fmt:formatDate pattern="yyyy-MM-dd" value="${goods.produceDate}"/>
            </td>
        </tr>
        <tr>
            <td>入库时间:</td>
            <td>
                <fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${goods.insertTime}"/>
            </td>
        </tr>
        <tr>
            <td>商品日志:</td>
            <td>
                <c:forEach items="${logs}" var="log" varStatus="i">
                    ${i.index != 0 ? '<br/>':''}
                    ${log.insertTime} - ${log.department.name}
                </c:forEach>
            </td>
        </tr>
        <tr>
            <td valign="top">备注:</td>
            <td>
                <textarea id="memo" name="memo" rows="4" class="span6">${goods.memo}</textarea>
            </td>
        </tr>
        <tr>
            <td colspan="2" class="text-center">
                <input class="btn" type="submit" value="提交"/>
                &nbsp;
                <input class="btn" type="button" value="返回" back="back" onclick="history.go(-1)"/>
            </td>
        </tr>
    </table>
</form>
</body>
</html>